{% extends "profilebase.html" %}


{% block sidebar2 %}
	{% if profileOwner %}
		<h4>Upload a new photo</h4>
		<form action="/myprofile/addPhoto/" method="post" enctype="multipart/form-data">{% csrf_token %}
			{{ form.non_field_errors }}
			{% for field in form %}
				<div class="fieldWrapper">
				{{ field.label_tag }}
				{% if error_message %}
					<br/><br/><label class="text" style="color:#FF0000" >{{ error_message }}</label><br/>
				{% endif %}
				{% if field.errors %}
					<br/><br/><label class="text" style="color:#FF0000;" >Maybe choose a photo before trying to upload...</label><br/>
				{% endif %}
				{{ field }}
				<br/><br/>Caption:<br/><input type="text" name="caption"/><br/><br/>
				<input type="submit" id="search_btn" value="Upload" />
				</div>
			{% endfor %}  	
		</form>
	{% endif %}
{% endblock %}

{% block content %}
{% if profileOwner %}
	<h1>My Photos</h1>
{% else %}
	<h1><a href="/myprofile/{{ currentUser.abstract_user.id }}/">{{ currentUser.abstract_user }}'s</a> Photos</h1>
{% endif %}

{% if del_success_message %}<font class="success">{{ del_success_message }}</font><br/>{% endif %}
{% if add_success_message %}<font class="success">{{ add_success_message }}</font><br/>{% endif %}

{% for photo in photos %}
	{% if photo.caption %}{{ photo.caption }}<br/><br/>{% endif %}
	<img border="0" src={{ photo.path }}></img><br/><br/><br/>
	{% if profileOwner %}
		<small><a href="/myprofile/deletePhoto/{{ photo.id }}/">delete</a></small>
	{% endif %}
	<br/><br/>
{% empty %}
	No photos added yet.
{% endfor %}
{% endblock %}
